package com.xydtech.ecard.merchant.controller;


import com.xydtech.common.annotation.Log;
import com.xydtech.common.core.controller.BaseController;
import com.xydtech.common.core.domain.AjaxResult;
import com.xydtech.common.core.domain.entity.SysDept;
import com.xydtech.common.core.page.TableDataInfo;
import com.xydtech.common.enums.BusinessType;
import com.xydtech.common.utils.ShiroUtils;
import com.xydtech.common.utils.poi.ExcelUtil;
import com.xydtech.ecard.merchant.domain.EcardOvertimeNotVisit;
import com.xydtech.ecard.merchant.service.IEcardOverTimeNotVisitService;
import com.xydtech.system.service.ISysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/*
    @Author yuzhiguo
    @Date 2023/11/3 16:33
    @Version v1.0
    @Description 网点商户统计超时未拜访明细Controller
*/
@Controller
@RequestMapping("/merchant/branchMerchant/overtimeNotVisit")
public class EcardOverTimeNotVisitController extends BaseController {
    @Autowired
    private IEcardOverTimeNotVisitService ecardOverTimeNotVisitService;
    @Autowired
    private ISysDeptService sysDeptService;

    private String prefix = "merchant";

//    @RequiresPermissions("merchant:overtimeNotVisit:view")
    @GetMapping("/{deptId}")
    public String visit(@PathVariable("deptId") String deptId, ModelMap mmap)
    {
        mmap.put("deptId", deptId);
        return prefix + "/overtimeNotVisit";
    }

    /**
     * 查询网点商户统计超时未拜访明细列表
     * @param ecardOvertimeNotVisit
     * @return
     */
//    @RequiresPermissions("merchant:overtimeNotVisit:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(EcardOvertimeNotVisit ecardOvertimeNotVisit) {
        SysDept sysDept = sysDeptService.selectSecondLevelDeptByDeptId(ShiroUtils.getSysUser().getDeptId());
        ecardOvertimeNotVisit.setDictDeptId(sysDept.getDeptId());
        startPage();
        List<EcardOvertimeNotVisit> list = ecardOverTimeNotVisitService.selectOvertimeNotVisit(ecardOvertimeNotVisit);
        return getDataTable(list);
    }

//    @RequiresPermissions("merchant:overtimeNotVisit:export")
    @Log(title = "导出网点商户统计超时未拜访明细列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(EcardOvertimeNotVisit ecardOvertimeNotVisit)
    {
        SysDept sysDept = sysDeptService.selectSecondLevelDeptByDeptId(ShiroUtils.getSysUser().getDeptId());
        ecardOvertimeNotVisit.setDictDeptId(sysDept.getDeptId());
        List<EcardOvertimeNotVisit> list = ecardOverTimeNotVisitService.selectOvertimeNotVisit(ecardOvertimeNotVisit);
        ExcelUtil<EcardOvertimeNotVisit> util = new ExcelUtil<EcardOvertimeNotVisit>(EcardOvertimeNotVisit.class);
        return util.exportExcel(list, "超时未拜访明细信息");
    }
}
